﻿using System;
using System.Collections.Generic;
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;

namespace SwHelper
{
    class DrawHelper
    {
        public SldWorks _swapp { get; set; }

        public DrawHelper(SldWorks _app)
        {
            this._swapp = _app;
        }

        /// <summary>
        /// 插入零件明细表
        /// </summary>
        /// <param name="swView"></param>
        /// <param name="_x"></param>
        /// <param name="_y"></param>
        /// <param name="alignment">对其方式 1.左上 2.右上 3.右下 4.左下</param>
        /// <param name="isTopOnly">明细表显示类型 1.swBomType_TopLevelOnly 2.swBomType_Indented 3.swBomType_PartsOnly</param>
        /// <param name="template">模板</param>
        public static BomTableAnnotation InserBomTable(View swView, double _x, double _y, int bomType, string template, int alignment = 4)
        {
            int tabAlignment = 0;
            switch (alignment)
            {
                case 1: tabAlignment = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft; break;
                case 2: tabAlignment = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopRight; break;
                case 3: tabAlignment = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomRight; break;
                case 4: tabAlignment = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomLeft; break;
                default: tabAlignment = (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomLeft; break;
            }
            int tabBomType = 0;
            switch (bomType)
            {
                case 1: tabBomType = (int)swBomType_e.swBomType_TopLevelOnly; break;
                case 2: tabBomType = (int)swBomType_e.swBomType_Indented; break;
                case 3: tabBomType = (int)swBomType_e.swBomType_PartsOnly; break;
                default: tabBomType = (int)swBomType_e.swBomType_TopLevelOnly; break;
            }
            BomTableAnnotation bomTable = swView.InsertBomTable4(false, _x, _y, tabAlignment, tabBomType, "默认", template, false, (int)swNumberingType_e.swNumberingType_Flat, false);

            return bomTable;
        }

    }
}
